package com.softpo.pointersgesture;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;

import com.softpo.pointersgesture.widget.MoveImage;

public class MainActivity extends AppCompatActivity {

    private MoveImage monkey;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        monkey = (MoveImage) findViewById(R.id.monkey);
    }

    /**
     * 该方法，可以写到控件中，自定义View
     * @param event
     * @return
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {

        //1、获取event，几个手指
        int pointerCount = event.getPointerCount();

        switch (pointerCount){
            case 1://一个手指
                //移动
                monkey.moveImage(event);
                break;
            case 2://两个手指
                //缩放
                monkey.scaleImage(event);
                break;
        }



        return super.onTouchEvent(event);
    }
}
